package com.yuexunit.operationman.nbsy.module.SafeOperation.ui.fragment;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.yuexunit.operationman.nbsy.R;
import com.yuexunit.operationman.nbsy.config.AppConfig;
import com.yuexunit.operationman.nbsy.module.SafeOperation.bean.SafeOperationBean;
import com.yuexunit.operationman.nbsy.module.SafeOperation.ui.Act_SafeOperation_Preview;

import org.kymjs.kjframe.ui.KJFragment;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by work-jx on 2017/7/11.
 */
public class Fragment_SO_BeforeOperation extends KJFragment {
    @Bind(R.id.frag_so_bo_tv_01)
    TextView fragSoBoTv01;
    @Bind(R.id.frag_so_bo_tv_02)
    TextView fragSoBoTv02;
    @Bind(R.id.frag_so_bo_tv_03)
    TextView fragSoBoTv03;
    @Bind(R.id.frag_so_bo_tv_04)
    TextView fragSoBoTv04;
    @Bind(R.id.frag_so_bo_tv_05)
    TextView fragSoBoTv05;
    @Bind(R.id.frag_so_bo_tv_06)
    TextView fragSoBoTv06;
    @Bind(R.id.frag_so_bo_tv_07)
    TextView fragSoBoTv07;
    @Bind(R.id.frag_so_bo_tv_08)
    TextView fragSoBoTv08;
    @Bind(R.id.frag_so_bo_tv_09)
    TextView fragSoBoTv09;
    @Bind(R.id.frag_so_bo_tv_10)
    TextView fragSoBoTv10;
    @Bind(R.id.frag_so_bo_tv_11)
    TextView fragSoBoTv11;
    @Bind(R.id.frag_so_bo_tv_12)
    TextView fragSoBoTv12;
    @Bind(R.id.frag_so_bo_tv_13)
    TextView fragSoBoTv13;
    private Act_SafeOperation_Preview aty;
    protected View mMainView;

    @Override
    protected View inflaterView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
        aty = (Act_SafeOperation_Preview) getActivity();
        mMainView = layoutInflater.inflate(R.layout.fragment_so_beforeoperation, viewGroup, false);
        ButterKnife.bind(this, mMainView);
        return mMainView;
    }


    @Override
    protected void initData() {
        fragSoBoTv11.setText(AppConfig.SAFEOPERATIONBEAN.getObject().getSecurity().getOperationSign());
        fragSoBoTv12.setText(AppConfig.SAFEOPERATIONBEAN.getObject().getSecurity().getAnesthetistSign());
        fragSoBoTv13.setText(AppConfig.SAFEOPERATIONBEAN.getObject().getSecurity().getNurseSign());
        for (SafeOperationBean.ObjectEntity.SecurityItemListEntity p : AppConfig.SAFEOPERATIONBEAN.getObject().getSecurityItemList()) {
            switch (p.getItemCode()) {
                case "OS_HuanZheXinXi":
                    if (p.getItemValue().equals("1")) {
                        fragSoBoTv01.setText("是");
                    } else if (p.getItemValue().equals("0")) {
                        fragSoBoTv01.setText("否");
                    }
                    break;
                case "OS_ShouShuFangShi":
                    if (p.getItemValue().equals("1")) {
                        fragSoBoTv02.setText("是");
                    } else if (p.getItemValue().equals("0")) {
                        fragSoBoTv02.setText("否");
                    }
                    break;
                case "OS_ShouShuBuWei":
                    if (p.getItemValue().equals("1")) {
                        fragSoBoTv03.setText("是");
                    } else if (p.getItemValue().equals("0")) {
                        fragSoBoTv03.setText("否");
                    }
                    break;
                case "OS_ShouShuYiShiChenShu":
                    if (p.getItemValue().length() > 0) {
                        String[] array = p.getItemValue().split(";");
                        String content = "";
                        String[] arrays = getResources().getStringArray(R.array.safeoperation_bo_01);
                        for (int i = 0; i < array.length; i++) {
                            switch (array[i]) {
                                case "1":
                                    if (content.length() > 0) {
                                        content += "\n";
                                        content += arrays[0];
                                    }
                                    else {
                                        content += arrays[0];
                                    }
                                    break;
                                case "2":
                                    if (content.length() > 0) {
                                        content += "\n";
                                        content += arrays[1];
                                    }
                                    else {
                                        content += arrays[1];
                                    }
                                    break;
                                case "3":
                                    if (content.length() > 0) {
                                        content += "\n";
                                        content += arrays[2];
                                    }
                                    else {
                                        content += arrays[2];
                                    }
                                    break;
                                case "4":
                                    if (content.length() > 0) {
                                        content += "\n";
                                        content += arrays[3];
                                    }
                                    else {
                                        content += arrays[3];
                                    }
                                    break;
                            }
                        }
                        fragSoBoTv05.setText(content);
                    }
                    break;
                case "OS_MaZuiYiShiChenShu":
                    if (p.getItemValue().length() > 0) {
                        String[] array = p.getItemValue().split(";");
                        String content = "";
                        String[] arrays = getResources().getStringArray(R.array.safeoperation_bo_02);
                        for (int i = 0; i < array.length; i++) {
                            switch (array[i]) {
                                case "1":
                                    if (content.length() > 0) {
                                        content += "\n";
                                        content += arrays[0];
                                    }
                                    else {
                                        content += arrays[0];
                                    }
                                    break;
                                case "2":
                                    if (content.length() > 0) {
                                        content += "\n";
                                        content += arrays[1];
                                    }
                                    else {
                                        content += arrays[1];
                                    }
                                    break;
                            }
                        }
                        fragSoBoTv06.setText(content);
                    }
                    break;
                case "OS_ShouShuHuShiChenShu":
                    if (p.getItemValue().length() > 0) {
                        String[] array = p.getItemValue().split(";");
                        String content = "";
                        String[] arrays = getResources().getStringArray(R.array.safeoperation_bo_03);
                        for (int i = 0; i < array.length; i++) {
                            switch (array[i]) {
                                case "1":
                                    if (content.length() > 0) {
                                        content += "\n";
                                        content += arrays[0];
                                    }
                                    else {
                                        content += arrays[0];
                                    }
                                    break;
                                case "2":
                                    if (content.length() > 0) {
                                        content += "\n";
                                        content += arrays[1];
                                    }
                                    else {
                                        content += arrays[1];
                                    }
                                    break;
                                case "3":
                                    if (content.length() > 0) {
                                        content += "\n";
                                        content += arrays[2];
                                    }
                                    else {
                                        content += arrays[2];
                                    }
                                    break;
                                case "4":
                                    if (content.length() > 0) {
                                        content += "\n";
                                        content += arrays[3];
                                    }
                                    else {
                                        content += arrays[3];
                                    }
                                    break;
                            }
                        }
                        fragSoBoTv07.setText(content);
                    }
                    break;
                case "OS_ShouShuTiWei":
                    if (p.getItemValue().equals("1")) {
                        fragSoBoTv04.setText("是");
                    } else if (p.getItemValue().equals("0")) {
                        fragSoBoTv04.setText("否");
                    }
                    break;
                case "OS_XiangGuanYingXiang":
                    if (p.getItemValue().equals("1")) {
                        fragSoBoTv08.setText("是");
                    } else if (p.getItemValue().equals("0")) {
                        fragSoBoTv08.setText("否");
                    }
                    break;
                case "OS_TiemOut":
                    if (p.getItemValue().equals("1")) {
                        fragSoBoTv09.setText("是");
                    } else if (p.getItemValue().equals("0")) {
                        fragSoBoTv09.setText("否");
                    }
                    break;
                case "OS_Other":
                    fragSoBoTv10.setText(p.getItemValue());
                    break;
            }
        }
    }
}
